
package com.omt.esouk.login;

import java.io.IOException;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.springframework.context.annotation.Scope;

@Scope("session")
@Named("loginBean")
public class LoginBean {

	private String login;

	private String password;

	public String doLogin() throws IOException, ServletException {

		ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();

		RequestDispatcher dispatcher = ((ServletRequest) context.getRequest())
		                .getRequestDispatcher("/j_spring_security_check");

		dispatcher.forward((ServletRequest) context.getRequest(), (ServletResponse) context.getResponse());

		FacesContext.getCurrentInstance().responseComplete();

		return null;

	}

	
    public String getLogin() {
    
    	return login;
    }

	
    public void setLogin(String login) {
    
    	this.login = login;
    }

	
    public String getPassword() {
    
    	return password;
    }

	
    public void setPassword(String password) {
    
    	this.password = password;
    }
}
